#include <REGX52.H>
#include "stdio.h"
unsigned char ch;
unsigned char Flag=1;
void Delay(unsigned int xms)		//@11.0592MHz
{
	unsigned char i, j;
 
	while(xms--)
	{
		i = 2;
		j = 199;
		do
		{
			while (--j);
		} while (--i);
	}
}
 
void UartInit(void)		//9600bps@11.0592MHz
{
	PCON &= 0x7F;		//??????
	SCON = 0x50;		//8???,?????
	TMOD &= 0x0F;		//?????1???
	TMOD |= 0x20;		//?????1?8???????
	TL1 = 0xFD;		//??????
	TH1 = 0xFD;		//????????
	ET1 = 0;		//?????1??
	TR1 = 1;		//?????1
	EA=1;
	ES=1;
}
void UartSend()
{
		TI=1;
		puts("Hello C51");
		while(!TI);
		TI=0;
		Delay(2000);
}
 
void main()
{
	UartInit();
	while(1)
	{
		if(Flag==1)UartSend();
	}	
}
 
 
//????????
void UART_Routine()	interrupt 4 //????
{
	if(RI==1)
	{
		RI=0;
		ch=SBUF;
		if(ch=='1')Flag=1;
		if(ch=='0')Flag=0;
	}
}